from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.item import Item
from core.support import get_game
import logging
from core.game import Game
from items.kite import Kite
from items.sunglassrig import usesunglassrig
from items.earingrig import useearingrig
from items.earing import Earing
from items.earingrig import Earingrig
from items.sunglassrig import Sunglassrig
from items.sunglasses import Sunglasses

class Sea6Fishing(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)

       # do basic initialization for every room
        #add inventory items
        self.fish_locked = True
        self.add_action(Fishwithhands)
        self.add_action(Reelinfish)
        self.add_item(Kite())
        # does the player have a lit lamp?
        # build list of actions
     
    # return description of room.
    def get_description(self):
        return "You successfully swam past the shark and got the food, but the rations only stymied your hunger for a few days.  You gaze out towards the horizon and spot out of the corner of your eye, a school of fish.  You also notice a kite.  You'll need some fishing line and something shiny and sharp to catch a fish.  Chose items from your inventory to catch a fish."
        #return "The sun is high and the seas are calm. " + self.game.get_player().getPlayerName() + " looks out from " + self.game.get_player().getPlayerPosessionPronoun() + " beachside villa at the waves lapping at the shore. Despite the demands on a Fortune 500 CEO, today is a good day for a sail. There is no time to make multiple trips between the villa and the boathouse and you can only carry six items. You'll only be gone a few hours, how much do you really need? "
        
    # return image of room
    def get_image(self):
        return 'sea6fishing_pic.jpg'

    def fishon(self):
        game = get_game()
        player = game.get_player()
        logging.info("&&&&&&&&& IN IS INUSE method of Sea6Fishing &&&&&&&&&&&&")
        logging.info(player.inventory)
        #'''if 'Sunglassrig' in player.inventory:
            #boolValue=player.inventory['Sunglassrig'].inuse        
            #logging.info(boolValue)'''
        if 'earingrig' in player.inventory:
            if player.inventory['earingrig'].inuse:
                return True
        if 'Sunglassrig' in player.inventory:
            if player.inventory['Sunglassrig'].inuse:
                return True
    
class Sea6FishingHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Sea6Fishing

    
# define actions for this room

class Reelinfish(Action):
    def __init__(self):
        Action.__init__(self, "Reelinfish")    # do basic initialization for every action
    
    def do_action(self,game,room,request):
        #set_cutscene(".")
        player = game.get_player()
        logging.info("player inventory is::::::::::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
        logging.info("heloooooooo")
        logging.info(player.inventory)
        if 'earingrig' in player.inventory:
            player.pop_item('earingrig')
        if 'Sunglassrig' in player.inventory:
            player.pop_item('Sunglassrig')
        # return description of action (used in label on webpage)
    def get_description(self):
        return "Reel in a fish"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'sea7caughtfish'

    def get_method(self):
        return "get"
    
    def is_enabled(self):
        if self.room.fishon():
            return True
        else:
            return False

class Fishwithhands(Action):
    def __init__(self):
        Action.__init__(self, "Fishwithhands")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Fish with your hands"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'fishwithhandsdeath'
    
    def get_method(self):
        return "get"


